<route lang="json5" type="page">
{
  layout: 'default',
  navigationStyle: 'custom',
}
</route>

<template>
  <view class="pt-3 pb-3">
    <view class="px-3 mb-3">
      <view class="p-3 bg-white rounded-4 overflow-hidden">
        <view class="font-bold border-b-[#f2f2f2] border-b border-b-solid pb-2">
          紧急任务（{{ urgentList.length }}项）
        </view>
        <view class="leading-relaxed">
          <view class="py-2" v-for="(item, i) in urgentList" :key="i">
            {{ i + 1 }}、{{ detail.urgent }}
          </view>
          <view class="text-right">
            <wd-text type="primary" text="去处理" @click="handleUrgent"></wd-text>
          </view>
        </view>
      </view>
    </view>
    <view class="px-3 mb-3">
      <view class="p-3 bg-white rounded-4 overflow-hidden">
        <view class="font-bold border-b-[#f2f2f2] border-b border-b-solid pb-2">
          重要任务（{{ importantList.length }}项）
        </view>
        <view class="pt-2 leading-relaxed">
          <view v-for="(item, i) in importantList" :key="i">{{ i + 1 }}、{{ item }}</view>
          <view class="text-right">
            <wd-text type="primary" text="去处理" @click="handleImportant"></wd-text>
          </view>
        </view>
      </view>
    </view>
    <view class="px-3 mb-3">
      <view class="p-3 bg-white rounded-4 overflow-hidden">
        <view class="font-bold border-b-[#f2f2f2] border-b border-b-solid pb-2">指标完成</view>
        <view class="pt-2 leading-relaxed">
          <view v-for="(item, i) in completeList" :key="i">{{ i + 1 }}、{{ item }}</view>
        </view>
      </view>
    </view>
    <view class="px-3">
      <view class="p-3 bg-white rounded-4 overflow-hidden">
        <view class="font-bold border-b-[#f2f2f2] border-b border-b-solid pb-2">业主服务行动</view>
        <view class="pt-2 leading-relaxed">
          <view>
            <view>1、重点业主关怀</view>
            <view class="flex justify-between">
              <text>{{ servicesList[0] }}</text>
              <wd-text type="primary" text="去查看"></wd-text>
            </view>
          </view>
          <view>
            <view>2、缴费提醒</view>
            <view class="flex justify-between">
              <text>{{ servicesList[1] }}</text>
              <wd-text type="primary" text="去处理" @click="handleFees"></wd-text>
            </view>
          </view>
          <view class="flex flex-col">
            <view>3、多经线索</view>
            <view class="flex">
              {{ servicesList[2] }}
            </view>
            <view class="flex justify-between">
              {{ servicesList[3] }}
              <wd-text type="primary" text="去处理" @click="handleDuojing"></wd-text>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { todayWork } from './api/index'

const id = ref('')
onLoad(async (options) => {
  id.value = options.id

  getListByTask()
})

const detail = ref()
const urgentList = ref([])
const importantList = ref([])
const completeList = ref([])
const servicesList = ref([])
async function getListByTask() {
  try {
    const { data } = await todayWork(id.value)
    detail.value = data
    urgentList.value = data.urgent.split('/n')
    importantList.value = data.important.split('/n')
    completeList.value = data.complete.split('/n')
    servicesList.value = data.services.split('/n')
    console.log(servicesList.value)
  } catch (error) {}
}

function handleUrgent() {
  uni.navigateTo({
    url: '/pages-sub/work-order/create?id=14',
  })
}
function handleImportant() {
  uni.navigateTo({
    url: '/pages-sub/inspection/index',
  })
}

function handleFees() {
  uni.navigateTo({
    url: '/pages/fees/recommend',
  })
}

function handleDuojing() {
  uni.navigateTo({
    url: '/pages/duojing/recommend',
  })
}
</script>

<style lang="scss" scoped>
//
</style>
